/*
 * To change this license header, choose License Headers in Project Properties. To change this
 * template file, choose Tools | Templates and open the template in the editor.
 */
package chalmers.game.subterranean.ui.view;

import chalmers.game.subterranean.event.Bus;
import chalmers.game.subterranean.event.events.RestartGameEvent;
import chalmers.game.subterranean.util.options.Backgrounds;
import chalmers.game.subterranean.util.options.WorldValues;
import com.google.common.eventbus.Subscribe;
import javafx.application.Platform;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.control.Label;
import javafx.scene.layout.Pane;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;

/**
 * 
 * @author TH
 */
public class EndScreen {

  public final Group view;

  public EndScreen() {

    view = new Group();

    Pane back = new Pane();
    Label text = new Label("YOU DIED!\nPRESS BACKSPACE TO RESTART");
    text.setTextAlignment(TextAlignment.CENTER);
    text.setFont(new Font(48));
    text.setPrefSize(WorldValues.GAME_RESOLUTION_WIDTH, WorldValues.GAME_RESOLUTION_HEIGHT);
    text.setAlignment(Pos.CENTER);
    back.setBackground(Backgrounds.START_BG);

    view.getChildren().addAll(back, text);
    view.setVisible(false);
    Bus.INSTANCE.register(this);
  }

  @Subscribe
    public void handleRestartGame(RestartGameEvent evt) {
        Platform.runLater(() -> {
            view.setVisible(true);
        });
    }
}
